package service.impl;

import entity.BlackCartridge;
import entity.ColorCartridge;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import service.PrinterService;
@Service("printerService")
public class PrinterServiceImpl implements PrinterService {
    @Qualifier("blackCartridge")
    @Autowired
    private BlackCartridge blackCartridge;
    @Qualifier("colorCartridge")
    @Autowired
    private ColorCartridge colorCartridge;

    public BlackCartridge getBlackCartridge() {
        return blackCartridge;
    }

    public void setBlackCartridge(BlackCartridge blackCartridge) {
        this.blackCartridge = blackCartridge;
    }

    public ColorCartridge getColorCartridge() {
        return colorCartridge;
    }

    public void setColorCartridge(ColorCartridge colorCartridge) {
        this.colorCartridge = colorCartridge;
    }

    @Override
    public void print(String text, String cartridgeType) {
        if ("black".equals(cartridgeType)) {
            System.out.println(blackCartridge.printText(text));
        } else if ("color".equals(cartridgeType)) {
            System.out.println(colorCartridge.printText(text));
        } else {
            System.out.println("无效的墨盒类型");
        }
    }
}
